package com.ken.android.music.view.presenter;

import android.content.pm.PackageManager;

import com.ken.android.music.data.MusicDataRepository;
import com.ken.android.music.model.MusicBean;
import com.ken.android.music.mvp.B.BasePresenter;

import java.util.List;
import java.util.concurrent.Future;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Scheduler;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class MusicListPresenter extends BasePresenter<MusicListContract.View> implements MusicListContract.Presenter {
    @Override
    public List<MusicBean> getMusicList(int id) {
//        if(id < 0){
            return MusicDataRepository.get().getTotalLocalMusic();
//        }
    }

    @Override
    public void asyncData(int id) {
        Observable.just(id)
                .subscribeOn(Schedulers.io())
                .map(new Function<Integer, List<MusicBean>>() {
                    @Override
                    public List<MusicBean> apply(Integer integer) throws Throwable {
                        return MusicDataRepository.get().getTotalLocalMusic();
                    }
                })
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<List<MusicBean>>() {
                    @Override
                    public void accept(List<MusicBean> musicBeans) throws Throwable {

                    }
                });
    }
}
